﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TaxInput.aspx.cs" Inherits="Admin.Tax.TaxInput" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>完税数据录入</title>
    <link href="/Admin/Css/rightbar.css?FileVersion=<%=FileVersion %>" rel="stylesheet"
        type="text/css" />
    <script src="/admin/Scripts/Calendar2008.js?FileVersion=<%=FileVersion %>" type="text/javascript"></script>
    <script src="/Admin/Scripts/jquery-1.4.1.min.js?FileVersion=<%=FileVersion %>" type="text/javascript"></script>
    <script src="/admin/Scripts/Check.js?FileVersion=<%=FileVersion %>" type="text/javascript"></script>
</head>
<body id="wallet">
    <div class="warp">
        <div class="topnav">
            <ul>
                <%if (HasPower("TaxList.aspx"))
                  { %>
                <li><a href="TaxList.aspx"><span>完税信息查询</span></a></li><%} %>
                <li><a href="javascript:void(0);" style="cursor: default;" class="on_nav"><span>新增完税记录</span></a></li>
            </ul>
        </div>
        <div class="tab mt15">
            <ul>
                <li class="in_on"><strong>新增完税记录</strong></li>
                <li class="caution01">带 <span class="org">*</span> 号为必填项目</li>
            </ul>
        </div>
        <div class="cont" style="padding-top: 8px;" id="stb8">
            <form id="form1" name="form1" action="TaxInput.aspx?action=add" method="post">
            <table width="660" border="0" cellspacing="0" cellpadding="0" class="tb01">
                <tr>
                    <td align="right" valign="middle" bgcolor="#F9F9F9">
                        <span class="org">*</span>房产证编号：
                    </td>
                    <td align="left" valign="top">
                        <input type="text" id="txtCertificateID" name="txtCertificateID" class="input200_out"
                            style="width: 240px;" need="房产证编号必须输入" /><span class="gray pl10">请输入房产证编号</span>
                    </td>
                </tr>
                <tr>
                    <td align="left" valign="middle" bgcolor="#F9F9F9" colspan="2" style="padding-left: 60px;">
                        <div id="divHouseInfo" style='padding-top: 5px; line-height: 150%; padding-left: 5px;
                            color: Red; display: <%= (hie == null ? "none" : "")%>;'>
                            房主姓名：<span id="spanName"><%=pName %></span>，身份证号：<span id="spanIDCardNum"><%=pIDCardNum%></span>，房产类型：<span
                                id="pHouseType"></span><br />
                            房产计税面积：<span id="pOriginalPrice"></span>，土地面积：<span id="pTudiArea"></span>,租金：<span
                                id="pRentPrice"></span>
                        </div>
                        <input type="hidden" id="txtRentID" name="txtRentID" />
                    </td>
                </tr>
                <tr>
                    <td align="right" valign="middle" bgcolor="#F9F9F9">
                        税款起止日期：
                    </td>
                    <td align="left" valign="top">
                        <input type="text" id="txtStartDate" name="txtStartDate" class="input200_out" style="width: 106px;"
                            maxlength="50" date="税款起始日期格式错" />
                        -
                        <input type="text" id="txtEndDate" name="txtEndDate" class="input200_out" style="width: 106px;"
                            maxlength="50" date="税款终止日期格式错" />
                    </td>
                </tr>
                <tr>
                    <td align="right" valign="middle" bgcolor="#F9F9F9">
                        税款属期与方式：
                    </td>
                    <td align="left" valign="middle">
                        <select id="selYear" name="selYear" style="width: 115px;">
                            <%=CreateYear(year) %>
                        </select><span style="padding-left: 13px;"></span>
                        <select id="selType" name="selType" style="width: 115px;">
                            <option value="分税种录入" selected="selected">分税种录入</option>
                            <option value="租金收入">租金收入</option>
                        </select><span class="gray pl10">请选择税款属期和方式</span>
                    </td>
                </tr>
                <tr id="tr1">
                    <td align="right" valign="middle" bgcolor="#F9F9F9">
                        是否完税：
                    </td>
                    <td align="left" valign="top">
                        <input type="radio" name="rdIsTaxOK" id="rdIsTaxOK0" value="0" checked="checked" /><label
                            for="rdIsTaxOK0">否</label>
                        <input type="radio" name="rdIsTaxOK" id="rdIsTaxOK1" value="1" /><label for="rdIsTaxOK1">是</label>
                        <span id="sComDate" style="padding-left: 10px; display: '';">完税日期：<input type="text"
                            id="txtComDate" name="txtComDate" class="input200_out" style="width: 92px;" maxlength="50"
                            date="完税日期格式错" /></span>
                    </td>
                </tr>
                <tr id="trTotal">
                    <td align="right" valign="middle" bgcolor="#F9F9F9">
                        税款总额：
                    </td>
                    <td align="left" valign="top">
                        <input type="text" id="txtTotalTax" name="txtTotalTax" class="input200_out" style="width: 240px;"
                            maxlength="50" float="税款总额必须位数字" />
                    </td>
                </tr>
                <tr>
                    <td align="right" valign="middle" bgcolor="#F9F9F9">
                        房产税：
                    </td>
                    <td align="left" valign="top">
                        <input type="text" id="txtFangchanTax" name="txtFangchanTax" class="input200_out"
                            style="width: 240px;" maxlength="50" float="房产税必须位数字" />
                    </td>
                </tr>
                <tr>
                    <td align="right" valign="middle" bgcolor="#F9F9F9">
                        土地使用税：
                    </td>
                    <td align="left" valign="top">
                        <input type="text" id="txtTudiTax" name="txtTudiTax" class="input200_out" style="width: 240px;"
                            maxlength="50" float="土地使用税必须位数字" />
                    </td>
                </tr>
                <tr name="hd">
                    <td align="right" valign="middle" bgcolor="#F9F9F9">
                        营业税：
                    </td>
                    <td align="left" valign="top">
                        <input type="text" id="txtYingyeTax" name="txtYingyeTax" class="input200_out" style="width: 240px;"
                            maxlength="50" float="营业税必须位数字" />
                    </td>
                </tr>
                <tr name="hd">
                    <td align="right" valign="middle" bgcolor="#F9F9F9">
                        个人所得税：
                    </td>
                    <td align="left" valign="top">
                        <input type="text" id="txtPersonalTax" name="txtPersonalTax" class="input200_out"
                            style="width: 240px;" maxlength="50" float="个人所得税必须位数字" />
                    </td>
                </tr>
                <tr name="hd">
                    <td align="right" valign="middle" bgcolor="#F9F9F9">
                        城市维护建设税：
                    </td>
                    <td align="left" valign="top">
                        <input type="text" id="txtCityTax" name="txtCityTax" class="input200_out" style="width: 240px;"
                            maxlength="50" float="城市维护建设税必须位数字" />
                    </td>
                </tr>
                <tr name="hd">
                    <td align="right" valign="middle" bgcolor="#F9F9F9">
                        教育费附加：
                    </td>
                    <td align="left" valign="top">
                        <input type="text" id="txtJiaoyuTax" name="txtJiaoyuTax" class="input200_out" style="width: 240px;"
                            maxlength="50" float="教育费附加必须位数字" />
                    </td>
                </tr>
                <tr name="hd">
                    <td align="right" valign="middle" bgcolor="#F9F9F9">
                        地方教育附加：
                    </td>
                    <td align="left" valign="top">
                        <input type="text" id="txtDifangJiaoyuTax" name="txtDifangJiaoyuTax" class="input200_out"
                            style="width: 240px;" maxlength="50" float="地方教育附加必须位数字" />
                    </td>
                </tr>
                <tr name="hd">
                    <td align="right" valign="middle" bgcolor="#F9F9F9">
                        印花税：
                    </td>
                    <td align="left" valign="top">
                        <input type="text" id="txtYinhuaTax" name="txtYinhuaTax" class="input200_out" style="width: 240px;"
                            maxlength="50" float="个人所得税必须位数字" />
                    </td>
                </tr>
            </table>
            </form>
        </div>
        <div class="btudiv">
            <ul style="width: 180px;">
                <li>
                    <input name="Submit1" type="submit" id="Submit1" class="button_sure" onclick="return CheckForm()"
                        value="确认添加" /></li>
            </ul>
        </div>
    </div>
    <script type="text/javascript">
        var c = new Calendar("c");
        c.offsetTop = 30;
        document.write(c);

        $(function () {
            //为日期输入框增加日历控件
            $(":input[date]").bind("focus", function (event) {
                c.showMoreDay = false;
                c.show(this); this.
                className = 'input60_on';
                this.onmouseout = ''
            });
        });

        var requireTaxInfo;
        //初始化
        jQuery(function ($) {
            ShowInputType("分税种录入");
            $("#selType").change(function () {
                ShowInputType($("#selType").val());
            });
            /*
            $("#rdIsTaxOK0").click(function () {
            $("#sComDate").css("display", "none");
            $("#txtComDate").val("")
            });
            $("#rdIsTaxOK1").click(function () {
            $("#sComDate").css("display", "");
            });
            */
            $("#txtCertificateID").blur(function () {
                GetHouseInfo();
            });
            $("#txtCertificateID").bind("keydown", function (event) {
                var e = event.keyCode || event.which;
                if (e == 13) {
                    GetHouseInfo();
                }
            });
            $("#txtTotalTax").blur(function () {
                CheckTax();
            });
            $("#txtTotalTax").bind("keydown", function (event) {
                var e = event.keyCode || event.which;
                if (e == 13) {
                    CheckTax();
                }
            });
        });
        //获取房屋信息
        function GetHouseInfo() {
            var certificateID = $("#txtCertificateID").val();
            if (certificateID == "") {
                return;
            }
            var url = "/Admin/AjaxPage/HouseInfo.aspx?action=gethousedetail&CertificateID=" + certificateID + "&year=" + $("#selYear").val() + "&timestamp=" + (new Date()).getTime();
            $.ajax({
                url: url,
                dataType: "json",
                success: function (data) {
                    if (data == "" || data[0].RequireTax == undefined) {
                        $("#divHouseInfo").css("display", "none");
                        var message = '';
                        if (data == "") {
                            message = "房产证编号不存请先录入房产信息，再添加完税信息";
                        }
                        else {
                            message = "该房产不存在应税信息，请查看商用房产信息是否完整";
                        }
                        alert(message);
                        $("#Submit1").attr("disabled", true);
                        requireTaxInfo = "";
                    }
                    else {
                        $("#txtRentID").val(data[0].RentID);
                        $("#spanName").html(data[0].Name);
                        $("#spanIDCardNum").html(data[0].IDCardNum);
                        $("#pOriginalPrice").html(data[0].OriginalPrice);
                        $("#pTudiArea").html(data[0].TudiArea);
                        $("#pHouseType").html(data[0].HouseType);
                        $("#pRentPrice").html(data[0].RentPrice);
                        $("#divHouseInfo").css("display", "");
                        $("#Submit1").attr("disabled", false);
                        ShowTaxType(data[0].HouseType);
                        requireTaxInfo = data[0].RequireTax; //alert(requireTaxInfo);
                    }
                },
                error: function (data) {
                    //alert("验证房屋信息失败，请刷新页面重试!");
                }
            });
        }

        function ShowInputType(type) {
            if (type == "分税种录入") {
                $("#trTotal").css("display", "none");
            }
            else {
                $("#trTotal").css("display", "");
            }
        }

        function ShowTaxType(houseType) {
            if (houseType == "出租") {
                $("tr[name='hd']").css("display", "");
            }
            else {
                $("tr[name='hd']").css("display", "none");
            }
        }

        //检查税种
        function CheckTax() {
            var taxType1 = $("#selType").val();
            if (requireTaxInfo == "" || taxType1 == "分税种录入") {
                //$("#Submit1").attr("disabled", false);
                return true;
            }
            else {
                if (taxType1 == "租金收入") {
                    var inputTotalTax = $("#txtTotalTax").val();
                    if (inputTotalTax != "") {
                        if (Number(inputTotalTax) < requireTaxInfo.TotalTax) {
                            alert("输入税款小于系统计算税款总额(" + requireTaxInfo.TotalTax + "),请按分税种录入方式操作");
                            $("#Submit1").attr("disabled", true);
                        }
                        else {
                            SetTaxControlValue("YingyeTax", requireTaxInfo.YingyeTax);
                            SetTaxControlValue("PersonalTax", requireTaxInfo.PersonalTax);
                            SetTaxControlValue("CityTax", requireTaxInfo.CityTax);
                            SetTaxControlValue("JiaoyuTax", requireTaxInfo.JiaoyuTax);
                            SetTaxControlValue("DifangJiaoyuTax", requireTaxInfo.DifangJiaoyuTax);
                            SetTaxControlValue("YinhuaTax", requireTaxInfo.YinhuaTax);
                            SetTaxControlValue("FangchanTax", requireTaxInfo.FangchanTax);
                            SetTaxControlValue("TudiTax", requireTaxInfo.TudiTax);
                            $("#Submit1").attr("disabled", false);
                        }
                    }
                }
            }
        }

        //为税收录入框赋值
        function SetTaxControlValue(name, value) {
            if (value > 0) {
                $("#txt" + name).val(value);
            }
        }
    </script>
    <script type="text/javascript">
        function CheckForm() {
            var obj = document.form1.elements;
            if (!checkAttr(obj)) {
                return false;
            }
            $("#form1").submit();
            return true;
        }
    </script>
</body>
</html>
